//
//  ScrollHiddle.m
//  BaseFrame
//
//  Created by 蓝水软件 on 2016/11/11.
//  Copyright © 2016年 xiaojiang. All rights reserved.
//

#import "ScrollHiddle.h"

@implementation ScrollHiddle
#define WIDTH [UIScreen mainScreen].bounds.size.width
#define HEIGHT [UIScreen mainScreen].bounds.size.height
- (void)hello{

    NSLog(@"hello world");
}

+ (void)scrollHiddl:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity withController:(UIViewController *)controller{

 
    
    if (velocity.y > 0.0)
    {
        //向上滑动隐藏导航栏
        if (controller.navigationController.navigationBar.alpha == 0.0) {
            return;
        }
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.5];
        controller.navigationController.navigationBar.alpha = 1.0;
        controller.navigationController.navigationBar.alpha = 0.0;
        controller.tabBarController.tabBar.alpha = 1.0;
        controller.tabBarController.tabBar.alpha = 0.0;
        [UIView commitAnimations];
        controller.navigationController.navigationBar.alpha = 0.0;
        controller.tabBarController.tabBar.alpha = 0.0;
        scrollView.frame = [UIScreen mainScreen].bounds;
    }else
    {
        if (controller.navigationController.navigationBar.alpha == 1.0) {
            return;
        }
        //向下滑动显示导航栏
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.5];
        controller.navigationController.navigationBar.alpha = 0;
        controller.navigationController.navigationBar.alpha = 1.0;
        controller.tabBarController.tabBar.alpha = 0.0;
        controller.tabBarController.tabBar.alpha = 1.0;
        [UIView commitAnimations];
        controller.navigationController.navigationBar.alpha = 1.0;
        controller.tabBarController.tabBar.alpha = 1.0;
        scrollView.frame = CGRectMake(0, 65,WIDTH,HEIGHT);
        
    }

}

+ (void)showBar:(UIViewController *)controller{
    
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];
    controller.navigationController.navigationBar.alpha = 0;
    controller.navigationController.navigationBar.alpha = 1.0;
    controller.tabBarController.tabBar.alpha = 0.0;
    controller.tabBarController.tabBar.alpha = 1.0;
    [UIView commitAnimations];
    controller.navigationController.navigationBar.alpha = 1.0;
    controller.tabBarController.tabBar.alpha = 1.0;



}
@end
